home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 112 / EnigmaAmiga112CD.iso / dalla rivista / awnpipe / awnp / awnp-docs / guidesign.doc < prev    next >
Text File  |  2000-05-14  |  3KB  |  76 lines

  1.  Working through these tutorials in order is the best way to learn to build GUI's with AWNPipe. A few minutes here will save you hours of development time later.
  2.  
  3.  TUTORIAL 1
  4. -----------
  5.  
  6. Building GUIs can be VERY easy, This first tutorial will develop a simple GUI.
  7.  
  8. Create a simple 4 line text file called first.gui. (You can use drag selection and Right-Amiga-C to copy text from these docs.)
  9.  
  10.  title "My first GUI" defaultgadgets
  11.  button gadgettext "YES"
  12.  button gt "NO"
  13.  open
  14.  
  15. Now, in a shell, type 'copy first.gui awnpipe:/xc'.
  16.  
  17. That was easy. You already guessed that gt was a short form for gadgettext.
  18.  
  19. Now we want to see what events the GUI sends. We can direct the events to a con by adding 'wcon:' to the end of the pipe name. Try
  20.  
  21. 'copy first.gui awnpipe:/xcwcon:'
  22.  
  23. Look at the output in the con:. Notice that the pipe replies to each line of the definition file, as well as sending events.
  24.  
  25. Now add a little text to the gui. We will also provide keyboard shortcuts for the gadgets.
  26.  
  27.  title "My first GUI" defaultgadgets
  28.  label  gt " Select YES or NO "
  29.  button gadgettext "_YES"
  30.  button gadgettext "_NO"
  31.  open
  32.  
  33. That worked, but it looks a little UGLY. Let's try a vertical layout instead of the default horizontal layout.
  34.  
  35.  title "My first GUI" defaultgadgets  vertical
  36.  label  gt " Select YES or NO "
  37.  button gadgettext "_YES"
  38.  button gadgettext "_NO"
  39.  open
  40.  
  41. The GUI is starting to look better, but we really want the two gadgets side-by-side. To do that, we will use a layout group. ("le" is short for "layout end".)
  42.  
  43.  title "My first GUI" defaultgadgets  vertical
  44.  label  gt " Select YES or NO "
  45.  layout
  46.  button gadgettext "_YES"
  47.  button gadgettext "_NO"
  48.  le
  49.  open
  50.  
  51. That is much better! The GUI looks good, but it would be nicer if the window closed after the user selected yes or no. (You should also notice that the layout received a GID number, so yes and no are now gadget 2 and 3.)
  52.  
  53.  title "My first GUI" defaultgadgets  vertical
  54.  label  gt " Select YES or NO "
  55.  layout
  56.  button gadgettext "_YES" close
  57.  button gadgettext "_NO" c
  58.  le
  59.  open
  60.  
  61. It's done and it might even be useful.
  62.  
  63. Since we have a working GUI, let's use it to see a few other types of events the GUI can generate.
  64.  
  65.  title "My first GUI" defaultgadgets  vertical  sendkeys sendqual help state
  66.  label  gt " Select YES or NO "
  67.  layout
  68.  button gadgettext "_YES" close
  69.  button gadgettext "_NO" c
  70.  le
  71.  open
  72.  
  73. Activate and deactivate the window. Hold the mouse over each gadget. Type a few keys. Try the shift, alt etc.
  74.  
  75.  
  76.